import { useQueryClient } from "@tanstack/react-query";
import { DeviceIcon } from "../device-icon";
import { useState } from "react";

export function SwitchState({ device }: { device: Pick<Device, "guid" | "type"> }) {



    const queryClient = useQueryClient();

    let msg = queryClient.getQueryData<DeviceState>(["state", device.guid]);

    let value: boolean = msg?.metrics.find((i) => i.name === "on")?.value;


    return (
        <p>
            {
                value ? "开" : "关"
            }
        </p>


    )

}
